{include file=header.subject.html}
<div class="static-header-{$init_data.id}">
	<div class="static-headerbg-{$init_data.id}"></div>
</div>
<div class="static-layout-{$init_data.id}">
	<div class="static-cont-{$init_data.id}">
		<!-- {foreach from=$init_data.children item=children name=child} -->
		<div class="cont static-cont-floor-{$smarty.foreach.child.index} f-cb return_top">
			<!-- {if $children.links} -->
			<a href="{$children.links}" target="_blank" class="more-btn"></a>
			<!-- {/if} -->
			<!-- {foreach from=$children.goods item=children_b name=child_b} -->
			<a href="{url app=goods&id=$children_b.goods_id}" target="_blank" class="listview">
				<div class="img">
					<img src="{$children_b.default_image}" width="237" height="237" />
				</div>
				<div class="title">{$children_b.goods_name}</div>
				<div class="price f-cb">
					<div class="price-left"> <i>￥</i>{$children_b.price}</div>
					<div class="price-right"></div>
				</div>
			</a>
			<!-- {/foreach} -->
		</div>
		<!-- {/foreach} -->
		<!-- {if $init_data.links} -->
		<div class="static-cont-more-{$init_data.id}">
			<a href="{$init_data.links}" target="_blank">
				<img src="{res file=images/subject/subject}{$init_data.id}/bg_btn.png" />
			</a>
		</div>
		<!-- {else} -->
		<div style="height:100px;overflow:hidden;"></div>
		<!-- {/if} -->
	</div>
</div>
<!-- bottom -->
<div class="border-bm-layout border-bgc-{$init_data.id}">
	<div class="border-bm border-bgc-{$init_data.id}"></div>
</div>
<ul class="subject-bar-{$init_data.id}" id="back_top">
	<!-- {foreach from=$init_data.children item=children name=child} -->
	<li class="click{$smarty.foreach.child.index}">
		<a href="javascript:void(0)" class="clickTo"></a>
	</li>
	<!-- {/foreach} -->
	<li>
		<a href="javascript:void(0)" class="top-touch"></a>
	</li>
</ul>
<script type="text/javascript">
function BackTop(settings) {
	this.conWidth = settings.conWidth;
	this.topDis = settings.topDis;
	this.container = null;
	this.topBtn = null;
	this.clickBtns = null;
	this.returnFloors = null;
	this.during =settings.during?settings.during:500;
	this.handle = {
		getWidth: function() {
			return $(window).width();
		},
		getScrollTop: function() {
			return $(window).scrollTop();
		}
	}
}
BackTop.prototype.init = function(settings) {
	var This = this;
	var returnFloorData = [];
	this.container = $(settings.conName);
	this.topBtn = $(settings.topName);
	this.clickBtns = this.container.find(settings.clickName);
	this.returnFloors = $(settings.returnName);
	this.topBtn.click(function() {
		$("html,body").stop().animate({
			scrollTop: 0
		}, This.during)
	});
	$.each(This.returnFloors,function(i){
		var b_top=$(this).offset().top;
		returnFloorData.push(b_top);
		if(This.clickBtns.eq(i).length>0){
			This.clickBtns.eq(i).bind('click',function(){
				$("html,body").stop().animate({
					scrollTop: b_top
				}, This.during);
			});
		}else{
			// alert('返回按钮'+i+'不够');
		}
	});
	if (This.handle.getScrollTop() > This.topDis) {
		This.container.show();
	}
	$(window).scroll(function() {
		if (This.handle.getScrollTop() > This.topDis) {
			if (This.handle.getWidth() > This.conWidth) {
				This.container.fadeIn();
				for(var j=0,lens=returnFloorData.length;j<lens;j++){
					if(returnFloorData[j+1]){
						if(This.handle.getScrollTop() >=returnFloorData[j] && This.handle.getScrollTop()<returnFloorData[j+1]){
							This.clickBtns.removeClass("active");
							This.clickBtns.eq(j).addClass("active");
							break;
						}
					}else{
						if(This.handle.getScrollTop() >=returnFloorData[j]){
							This.clickBtns.removeClass("active");
							This.clickBtns.eq(j).addClass("active");
						}
					}
				}
			}
		} else {
			This.container.fadeOut();
		}
	});
	$(window).resize(function() {
		if (This.handle.getWidth() < This.conWidth) {
			This.container.fadeOut();
		} else {
			if (This.handle.getScrollTop() > This.topDis) {
				This.container.fadeIn();
			}
		}
	});

};
$(function(){
	var backTop = new BackTop({
        'conWidth': 1600,
        'topDis': 300
    });
    backTop.init({
        'conName': '#back_top',
        'topName': '.top-touch',
        'clickName': '.clickTo',
        'returnName': '.return_top'
    });	
});
</script>
{include file=footer.index.simple.html}